package com.datatools.ui.basewindow;

import com.datatools.ui.frame.LeftPanel;
import com.datatools.ui.frame.LeftPanelTreeNode;
import com.datatools.util.SerializationUtil;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.Serializable;

public class BaseWindowAdapter extends WindowAdapter implements Serializable {
    @Override
    public void windowClosing(WindowEvent event) {
        //关闭前将当前类实例进行序列化
        JTree dbConTree = LeftPanel.getInstance().getDbConTree();
        LeftPanelTreeNode root = (LeftPanelTreeNode) dbConTree.getModel().getRoot();
        SerializationUtil.writeObject(root,root.getClass().getName());
    }

    @Override
    public void windowClosed(WindowEvent e) {
        super.windowClosed(e);
    }

    @Override
    public void windowOpened(WindowEvent e) {
        super.windowOpened(e);
    }
}
